package com.edu.zut.hb.software.server.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Collection;

import com.edu.zut.hb.software.server.pojo.UpdateVo.StudentUpdateVo;
import com.edu.zut.hb.software.server.pojo.registerVo.StudentRegisterVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * <p>
 *
 * </p>
 *
 * @author zhoubin
 * @since 2021-08-15
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@TableName("ks_student")
@ApiModel(value = "Student对象", description = "学生")
public class Student implements Serializable, UserDetails {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "名字")
    private String name;

    @ApiModelProperty(value = "学号")
    @TableId(value = "id", type = IdType.AUTO)
    private String id;

    @ApiModelProperty(value = "学生密码")
    private String password;

    @ApiModelProperty(value = "班级")
    private Integer clazz;

    public Student(String name, String password) {
        this.name = name;
        this.password = password;
    }

    @ApiModelProperty(value = "宿舍号")
    private Integer room;

    @ApiModelProperty(value = "身高")
    private Integer height;

    @ApiModelProperty(value = "体重")
    private Integer weight;

    @ApiModelProperty(value = "公里数1")
    private Float mileageTerm1;

    @ApiModelProperty(value = "公里数2")
    private Float mileageTerm2;

    @ApiModelProperty(value = "公里数3")
    private Float mileageTerm3;

    @ApiModelProperty(value = "公里数4")
    private Float mileageTerm4;

    @ApiModelProperty(value = "性别")
    private String sex;

    public Student(StudentRegisterVo registerVo) {
        this.name = registerVo.getUsername();
        this.password = registerVo.getPassword();
        this.clazz = registerVo.getClazz();
        this.room = registerVo.getRoom();
        this.height = registerVo.getHeight();
        this.weight = registerVo.getWeight();
        this.sex=registerVo.getSex();
    }
    public Student(StudentUpdateVo updateVo){
        this.id=updateVo.getId();
        this.name=updateVo.getName();
        this.clazz=updateVo.getClazz();
        this.room=updateVo.getRoom();
        this.mileageTerm1= updateVo.getMileageTerm1();
        this.mileageTerm2= updateVo.getMileageTerm2();
        this.mileageTerm3= updateVo.getMileageTerm3();
        this.mileageTerm4= updateVo.getMileageTerm4();
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getUsername() {
        return id;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
